package com.groupname.dangerousdelves;
import sofia.graphics.Color;
import java.util.*;

import sofia.graphics.ImageShape;

/**
 *  This class is the data structure representing the player's character.
 *
 *  @author Chris Fieldman (Chrisf90) sluke1
 *  @version 2012.11.04
 */
public class Player
    implements Actor
{
    //~-------------------------------------------------------------------------
    // Member Variables
    List<Weapon> weapons;
    List<Shield> shields;
    List<Armor> armor;

    //~-------------------------------------------------------------------------
    // Constructors
    /**
     * Create a new Player object.
     */
    public Player()
    {
        weapons = new ArrayList<Weapon>();
        shields = new ArrayList<Shield>();
        armor = new ArrayList<Armor>();

        weapons.add(new PunyDagger());
        shields.add(new WoodenBoard());
        armor.add(new LeatherChest());
    }

    //~-------------------------------------------------------------------------
    // Methods
    /**
     * Retrieves the type of actor for this tile.
     * @return Player, this is the player
     */
    public ActorType getActorType()
    {
        return ActorType.Player;
    }

    // ----------------------------------------------------------
    /**
     * Returns the currently equipped weapon.
     * @return the current weapon
     */
    public Weapon getCurrentWeapon()
    {
        for(int i = 0; i < weapons.size() - 1; i++)
        {
            if(weapons.get(i).getEquipped())
            {
                return weapons.get(i);
            }
        }
        return new PunyDagger();
    }

    // ----------------------------------------------------------
    /**
     * Sets a current weapon.
     * @param inWeapon the weapon to be used.
     */
    public void setCurrentWeapon(Weapon inWeapon)
    {
        for(int i = 0; i < weapons.size() - 1; i++)
        {
            weapons.get(i).setEquipped(false);
        }

        for(int i = 0; i < weapons.size() - 1; i++)
        {
            if(weapons.get(i).getDescription() == inWeapon.getDescription())
            {
                weapons.get(i).setEquipped(true);
            }
        }

    }

 // ----------------------------------------------------------
    /**
     * Returns the currently equipped shield.
     * @return the current shield
     */
    public Shield getCurrentShield()
    {
        for(int i = 0; i < shields.size() - 1; i++)
        {
            if(shields.get(i).getEquipped())
            {
                return shields.get(i);
            }
        }
        return new WoodenBoard();
    }

    // ----------------------------------------------------------
    /**
     * Sets a current shield.
     * @param inShield the shield to be used.
     */
    public void setCurrentShield(Shield inShield)
    {
        for(int i = 0; i < shields.size() - 1; i++)
        {
            shields.get(i).setEquipped(false);
        }

        for(int i = 0; i < shields.size() - 1; i++)
        {
            if(shields.get(i).getDescription() == inShield.getDescription())
            {
                shields.get(i).setEquipped(true);
            }
        }

    }

 // ----------------------------------------------------------
    /**
     * Returns the currently equipped armor.
     * @return the current armor
     */
    public Armor getCurrentArmor()
    {
        for(int i = 0; i < armor.size() - 1; i++)
        {
            if(armor.get(i).getEquipped())
            {
                return armor.get(i);
            }
        }
        return new LeatherChest();
    }

    // ----------------------------------------------------------
    /**
     * Sets a current armor.
     * @param inArmor the armor to be used.
     */
    public void setCurrentArmor(Armor inArmor)
    {
        for(int i = 0; i < armor.size() - 1; i++)
        {
            armor.get(i).setEquipped(false);
        }

        for(int i = 0; i < armor.size() - 1; i++)
        {
            if(armor.get(i).getDescription() == inArmor.getDescription())
            {
                armor.get(i).setEquipped(true);
            }
        }

    }

    public Color getColor()
    {
        return Color.blue;
    }
}